# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=lua-timerwheel
_pkgname=timerwheel
pkgver=1.0.2
pkgrel=1
pkgdesc="Efficient timer for timeout related timers"
url="https://tieske.github.io/timerwheel.lua/"
arch="noarch"
license="MIT"
depends="lua lua-coxpcall"
checkdepends="
	lua-busted
	lua-socket
	"
source="https://github.com/Tieske/timerwheel.lua/archive/$pkgver/timerwheel.lua-$pkgver.tar.gz"
builddir="$srcdir/timerwheel.lua-$pkgver"

case "$CARCH" in
	ppc64le|riscv64) _luajit="";;
	*) checkdepends="$checkdepends luajit"; _luajit="jit";;
esac

_luaversions="5.1 5.2 5.3 5.4"
for _v in $_luaversions; do
	checkdepends="$checkdepends lua$_v lua$_v-busted"
done

check() {
	local lver; for lver in $_luaversions $_luajit; do
		msg "Testing on lua$lver"
		lua$lver /usr/bin/busted --no-coverage
	done
}

package() {
	local luadir="$pkgdir/usr/share/lua/common"
	local rockdir="$pkgdir/usr/lib/luarocks/rocks-common/$_pkgname/$pkgver-1"

	mkdir -p "$luadir"
	cp -r src/* "$luadir"/

	mkdir -p "$rockdir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

sha512sums="
91855e66f1960d05f318800cdb9c0d7ee1574c28753fccd10944d85a26e74fe1892434d2f257d98ba463326867d59e9bc40516ce1f16a79c069576afc42e7f3a  timerwheel.lua-1.0.2.tar.gz
"
